<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.zrgk.com/mytag" prefix="page" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="html/Style/skin.css" />
    <script type="text/javascript" src="html/Js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript">
    	function state(obj){
    		var a=document.getElementById("a"+obj);
    		var span=document.getElementById("span"+obj);
    		var input=document.getElementById("input"+obj);
    			if(confirm("确认修改？")){
    				$.ajax({
						url:"emp.do?method=updateEmpState&id="+obj,
						type:"post",
						data:"state="+input.value,
						dataType:'json',
						success:function(d){
							if(d){
								if(input.value=="2"){
									a.innerHTML="禁用";
									span.innerHTML="启用";
									input.value="1";
								}else{
									a.innerHTML="启用";
									span.innerHTML="禁用";
									input.value="2";
								}	
							}
    					}
    				});
    		}
    	}
    	
    	function deleteEmp(obj){
    		if(confirm("确认删除？")){
    			$.ajax({
					url:"emp.do?method=deleteEmp",
					type:"post",
					data:"id="+obj,
					dataType:'json',
					success:function(d){
						if(d){
							alert("删除成功");
							history.go(0);
						}else{
							alert("删除失败");
						}
    				}
    			});
    		}
    	}
    	
    	
    	$(function(){
    		$("#selectAll").click(function(){    
     			$("input[type=checkbox]").attr("checked", true);   
        	});
			
			$("#reverse").click(function(){ 
				$("input[type=checkbox]").each(function(){
    				if(this.checked){    
        				$(this).attr("checked", false);   
    				}else{    
        				$(this).attr("checked", true); 
					}    
				}); 
			});
			
    	});
    </script>	    
</head>
    <body>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
            <!-- 头部开始 -->
            <tr>
                <td width="17" valign="top" background="html/Images/mail_left_bg.gif">
                    <img src="html/Images/left_top_right.gif" width="17" height="29" />
                </td>
                <td valign="top" background="html/Images/content_bg.gif">
                    <table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" background="./html/Images/content_bg.gif">
                        <tr><td height="31"><div class="title">员工管理</div></td></tr>
                    </table>
                </td>
                <td width="16" valign="top" background="html/Images/mail_right_bg.gif"><img src="html/Images/nav_right_bg.gif" width="16" height="29" /></td>
            </tr>
            <!-- 中间部分开始 -->
            <tr>
                <!--第一行左边框-->
                <td valign="middle" background="html/Images/mail_left_bg.gif">&nbsp;</td>
                <!--第一行中间内容-->
                <td valign="top" bgcolor="#F7F8F9">
                    <table style="width:100%" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                        <!-- 空白行-->
                        <tr><td colspan="2" valign="top">&nbsp;</td><td>&nbsp;</td><td valign="top">&nbsp;</td></tr>
						<tr>
							<td colspan="4">
								<form action="emp.do?method=findEmpbyPage" method="post" class="clearfix">
									<div style="float:left">
										<p style="float:left; margin-left:30px;"><label>员工姓名：</label><input name="empName" class="text" style="width:80px;" list="emplist"  value="" /></p>&nbsp;&nbsp;&nbsp;
										<p style="float:left; margin-left:30px;"><label>联系方式：</label><input name="empPhone" class="text" style="width:80px;" value="" /></p>&nbsp;&nbsp;&nbsp;
                                        <p style="float:left; margin-left:30px;"><label>所属部门：</label>
											<select name="mepDeptId">
												<option value="0">不限</option>
												<option>中软高科</option>
												<option>总经办</option>
												<option>综合部</option>
												<option>市场发展部</option>
												<option>销售一部</option>
												<option>销售二部</option>
												<option>销售三部</option>
												<option>财务科</option>
											</select>
										</p>&nbsp;&nbsp;&nbsp;
                                        <p style="float:left; margin-left:30px;"><label>修改时间：</label><input class="text" style="width:80px;" value="" /> - <input class="text" style="width:80px;" value="" /></p>&nbsp;&nbsp;
										<p style="float:left; margin-left:30px;"><input type="submit" class="btn" value="查询"/></p>
									</div>
									<div style="float:right">
										<input type="button" onclick="window.location='emp.do?method=addEmpBefore'" class="btn" value="员工录入"/> 
										<input type="button" id="btn" class="btn" value="批量删除"/>										
									
									</div>
								</form>
								<datalist id="emplist">
									<option value="张山"></option>
									<option value="李诗诗"></option>
									<option value="钟华"></option>
									<option value="秦士篁"></option>
									<option value="孙逸仙"></option>
									<option value="李德胜"></option>
									<option value="秦九韶"></option>
									<option value="常凯申"></option>
								</datalist>
							<td>
						</tr>
                        <!-- 一条线 -->
                        <tr>
                            <td height="40" colspan="4">
                                <table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
                                    <tr><td></td></tr>
                                </table>
                            </td>
                        </tr>
                        <!-- 列表展示开始 -->
                        <tr>
                            <td width="2%">&nbsp;</td>
                            <td width="96%">
                                <table width="100%">
                                    <tr>
                                        <td colspan="2">
                                            <form action="" method="">
                                                <table width="100%"  class="cont tr_color">
                                                    <tr>
                                                        <th>序号</th>
                                                        <th>选择</th>
                                                        <th>员工姓名</th>
                                                        <th>性别</th>
                                                        <th>联系方式</th>
														<th>所属部门</th>
                                                        <th>角色</th>
                                                        <th>最后修改时间</th>
                                                        <th>操作者</th>
														<th>当前状态</th>
                                                        <th>操作</th>
                                                    </tr>
                                                    <c:forEach items="${pageUtil.list}" var="emp" varStatus="vs" >
                                                    	 <tr align="center" class="d">
                                                   		<td>${vs.index+1}</td>
                                                        <td><input type="checkbox" name="ids" value="id" /></td>
                                                        <td><a href="emp.do?method=findEmpById&empId=${emp.id }">${emp.name}</a></td>
                                                        <td>
                                                        	<c:if test="${emp.sex==1}">男</c:if>
                                                        	<c:if test="${emp.sex==2}">女</c:if>
                                                        </td>
                                                        <td>${emp.phone }</td>
                                                        <td>${emp.dept.shortName }</td>
                                                        <td>${emp.role.name}</td>
														<td>${emp.lastDate}</td>
                                                        <td>${emp.user.name }</td>
                                                        <td >
                                                        	<input type="hidden" id="input${emp.id}" value="${emp.state}">
                                                        	<span id="span${emp.id}">
                                                        		<c:if test="${emp.state==1}">启用</c:if>
                                                        		<c:if test="${emp.state==2}">禁用</c:if>
                                                        	</span>
                                                        </td>
                                                         <td>
															<a id="a${emp.id}" href="javascript:state(${emp.id});" >
																
																<c:if test="${emp.state==1}">禁用</c:if>
																<c:if test="${emp.state==2}">启用</c:if>
															</a>&nbsp;&nbsp;
															<a href="emp.do?method=authoriseEmpBefore&id=${emp.id}">授权</a>&nbsp;&nbsp;
                                                        	<a href="emp.do?method=updateEmpBefore&empId=${emp.id }">修改</a>&nbsp;&nbsp;
                                                            <a href="javascript:deleteEmp(${emp.id})">删除</a>
														</td>
                                                    </tr>
                                                    </c:forEach>
                                                    
                                                  
                                                </table>
                                            </form>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td width="2%">&nbsp;</td>
                        </tr>
                        <!--列表展示结束 -->
                        <tr>
                            <td height="40" colspan="4">
                                <table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
                                    <tr><td></td></tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td width="2%">&nbsp;</td>
                            <td width="51%" class="left_txt">
                           		<input id="selectAll" type="button" value="全选" />&nbsp;&nbsp;&nbsp;
                                <input id="reverse"  type="button" value="反选" />
								<div style="float:right;"><b>
									<page:pagePrint url="emp.do?method=findEmpByPage" key="page" pageUtil="${pageUtil }"/>
								</b></div>
                            </td>
                            <td>&nbsp;</td><td>&nbsp;</td>
                        </tr>
                    </table>
                </td>
                <td background="html/Images/mail_right_bg.gif">&nbsp;</td>
            </tr>
            <!-- 底部部分 -->
            <tr>
                <td valign="bottom" background="html/Images/mail_left_bg.gif">
                    <img src="html/Images/buttom_left.gif" width="17" height="17" />
                </td>
                <td background="html/Images/buttom_bgs.gif">
                    <img src="html/Images/buttom_bgs.gif" width="17" height="17">
                </td>
                <td valign="bottom" background="html/Images/mail_right_bg.gif">
                    <img src="html/Images/buttom_right.gif" width="16" height="17" />
                </td>           
            </tr>
        </table>
    </body>
</html>